//
//  StoreView.m
//  FKGW
//
//  Created by song ce on 2017/2/21.
//  Copyright © 2017年 song ce. All rights reserved.
//

#import "StoreV.h"
#import "AppDelegate.h"
#import "LoginViewController.h"
@interface StoreV ()
@property (weak, nonatomic) IBOutlet UILabel *guanzhuLabel;
@property (weak, nonatomic) IBOutlet UIImageView *guanzhuImageView;

@property (weak, nonatomic) IBOutlet UILabel *sixinLabel;

@property (weak, nonatomic) IBOutlet UILabel *hujiaoLabel;
@property (weak, nonatomic) IBOutlet UIImageView *hujiaoImageView;

@property (weak, nonatomic) IBOutlet UILabel *watchLabel;

@property(nonatomic,assign)NSInteger status;
@end


@implementation StoreV

-(void)awakeFromNib{
    [super awakeFromNib];
   self.guanzhuLabel.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:14];
    self.sixinLabel.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:14];
    self.hujiaoLabel.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:14];
    self.watchLabel.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:14];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(setCallLiveBtnStatus:) name:@"setCallLiveBtnStatus" object:nil];
}

-(void)setCallLiveBtnStatus:(NSNotification*)noti{
    self.status = [noti.object integerValue];
    switch (self.status) {
        case CallLIiveDisenabled: //无法呼叫直播
        {
            self.hujiaoLabel.text = @"呼叫直播";
            self.hujiaoImageView.image=[UIImage imageNamed:@"content_icon_hujiaozhibo_dis"];
            self.hujiaoLabel.textColor =DEF_COLOR153;
          
        }
             break;
        case CallLIiveEnabled: //可以呼叫直播
        {
           self.hujiaoLabel.text = @"呼叫直播";
            self.hujiaoImageView.image=[UIImage imageNamed:@"content_icon_hujiaozhibo_nor"];
            self.hujiaoLabel.textColor =[UIColor colorWithRed:255./255 green:127./255 blue:108./255 alpha:1.];
        }
            break;
        case entryLivingRoom: //正在直播 进入店铺直播室
        {
            self.hujiaoLabel.text = @"进入直播";
            self.hujiaoImageView.image=[UIImage imageNamed:@"content_icon_jinruzhibo_nor"];
            self.hujiaoLabel.textColor =[UIColor colorWithRed:63./255 green:223./255 blue:0./255 alpha:1.];
        }
            break;
        default:
            break;
    }
}
- (IBAction)guanzhu:(UIButton*)sender {
    if(![AppDelegate appDealegate].uid.length){
        LoginViewController *login = [[LoginViewController alloc]init];
        login.isModel = YES;
        BaseNavigationViewController *baseNavi = [[BaseNavigationViewController alloc]initWithRootViewController:login];
        [[self baseViewController] presentViewController:baseNavi animated:YES completion:nil];
        return;
    }
    sender.selected = !sender.selected;
    if(sender.isSelected){
        self.guanzhuImageView.image =[UIImage imageNamed:@"content_icon_guanzhudainji_sel"];
        if(self.focusBlock){
            self.focusBlock(YES);
        }
    }else{
        self.guanzhuImageView.image =[UIImage imageNamed:@"content_icon_guanzhu_nor-1"];
        if(self.focusBlock){
            self.focusBlock(NO);
        }
    }
}

- (IBAction)sixin:(id)sender {
    if(![AppDelegate appDealegate].uid.length){
        LoginViewController *login = [[LoginViewController alloc]init];
        login.isModel = YES;
        BaseNavigationViewController *baseNavi = [[BaseNavigationViewController alloc]initWithRootViewController:login];
        [[self baseViewController] presentViewController:baseNavi animated:YES completion:nil];
        return;
    }

    if(self.privateMessageBlock){
        self.privateMessageBlock();
    }

}
- (IBAction)callLive:(id)sender {
    if(self.callLiveBlock){
        self.callLiveBlock(self.status);
    }
}

- (IBAction)watchVedio:(id)sender {
    if(self.watchLiveBlock){
        self.watchLiveBlock();
    }
}
- (BaseViewController*)baseViewController{
    UIResponder *next = self.nextResponder;
    while (next!=nil) {
        if([next isKindOfClass:[BaseViewController class]]){
            return (BaseViewController*)next;
        }
        next = next.nextResponder;
    }
    return nil;
}

@end
